package com.hstcs.creator;

import com.badlogic.ashley.core.Entity;
import com.badlogic.gdx.graphics.g2d.Animation;
import com.badlogic.gdx.graphics.g2d.Animation.PlayMode;
import com.hstcs.assets.Assets;
import com.hstcs.assets.Common;
import com.hstcs.assets.Config;
import com.hstcs.assets.FileName;
import com.hstcs.components.AnimationComponent;
import com.hstcs.components.BoundsComponent;
import com.hstcs.components.HeroComponent;
import com.hstcs.components.MovementComponent;
import com.hstcs.components.StateComponent;
import com.hstcs.components.TextureComponent;
import com.hstcs.components.TransformComponent;
import com.hstcs.game.God;

public class HeroCreator implements EntityCreator {

	
	static public Entity create(Entity crosshair){
		Entity entity = new Entity();
		AnimationComponent animation = new AnimationComponent();
		animation.animations.put(HeroComponent.STATE_IDEL, new Animation(0.6f, Assets.getRegionArray(FileName._AN_GUNNER, 6, 3, 0, 0), PlayMode.LOOP));
		animation.animations.put(HeroComponent.STATE_WALK, new Animation(0.3f, Assets.getRegionArray(FileName._AN_GUNNER, 6, 3, 1, 5), PlayMode.LOOP));
		animation.animations.put(HeroComponent.STATE_ATTACK, new Animation(0.6f, Assets.getRegionArray(FileName._AN_GUNNER, 6, 3, 6, 11), PlayMode.LOOP));		
		BoundsComponent bounds = new BoundsComponent();
		MovementComponent movement = new MovementComponent();
		TransformComponent position = new TransformComponent();
		StateComponent state = new StateComponent();
		TextureComponent texture = new TextureComponent();
		HeroComponent hero = new HeroComponent();
		hero.crosshair = crosshair;
		hero.maxVelocity = 200f;
	//	position.pos.set(0f, 0f, 1.0f);
		bounds.bounds.width = hero.WIDTH;
		bounds.bounds.height = hero.HIGHT;
		
	//	SteeringComponent steer = new SteeringComponent();
	//	steer.steeringBehavior = new 
		
		
		state.set(HeroComponent.STATE_IDEL);
		entity.add(animation);
		entity.add(bounds);
		entity.add(movement);
		entity.add(position);
		entity.add(state);
		entity.add(texture);
		entity.add(hero);
		
		God.instance.engine.addEntity(entity);
		return entity;
	}
}
